-- 设置leader键为<space>
vim.g.mapleader = " "
vim.g.maplocalleader = " "


-- 全局变量
local map = vim.api.nvim_set_keymap
local opt = {noremap = true, silent = true}

-- nvim-tree快捷键
map('n','<C-n>',':NvimTreeOpen<CR>',opt)
map('n','<C-w>',':NvimTreeClose<CR>',opt)
map('n','<C-t>',':NvimTreeFocus<CR>',opt)

-- rnvimr快捷键
map('n','<C-e>',':RnvimrToggle<CR>',opt)
map('t','<C-e>','RnvimrToggle<CR>',opt)
-- bufferline 快捷键
map("n", "<leader>h", ":BufferLineCyclePrev<CR>", opt)
map("n", "<leader>l", ":BufferLineCycleNext<CR>", opt)
map("n", "<leader>wl", ":BufferLineCloseLeft<CR>", opt)
map("n", "<leader>wr", ":BufferLineCloseRight<CR>", opt)
-- Markdown 快捷键
map("n","<C-p>",":MarkdownPreviewToggle<CR>",opt)
-- telescope 快捷键
map("n", "<leader>ff", 
    [[<cmd>lua require('telescope.builtin').find_files()<cr>]], {})


map("n", "<leader>fg", 
    [[<cmd>lua require('telescope.builtin').live_grep()<cr>]], {})

map("n", "<leader>fb", 
    [[<cmd>lua require('telescope.builtin').buffers()<cr>]], {})

map("n", "<leader>fh", 
    [[<cmd>lua require('telescope.builtin').help_tags()<cr>]], {})

map("n", "<leader>sf", 
    [[<cmd>lua require('telescope.builtin').file_browser()<cr>]], {})

map("n", "<leader>/", 
    [[<cmd>lua require'telescope.builtin'.current_buffer_fuzzy_find{}<CR>]], {})



-- lspsaga 快捷键
--
-- 开启悬浮终端
map("n", "<A-t>",
    [[<cmd>lua require('lspsaga.floaterm').open_float_terminal()<CR>]],opt)
-- 关闭悬浮终端
map("t", "<A-x>",
    [[<cmd>lua require('lspsaga.floaterm').close_float_terminal()<CR>]],opt)
-- async lsp finder
map("n", "<A-h>",
    [[<cmd>lua require'lspsaga.provider'.lsp_finder()<CR>]],opt)
-- 重命名
map("n", "<A-r>",
    [[<cmd>lua require('lspsaga.rename').rename()<CR>]], opt)


--- lazygit.nvim 快捷键
map("n","<leader>gg",":LazyGit<CR>",opt)
